#ifndef MISC_H
#define	MISC_H

/******************** INCLUDES ***********************/
#include "types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>

/****************************************************/

/******************** MACROS ************************/

#define IS_VALUE_1(X) ((1 - X) < 0.00001)

/****************************************************/

/******************** DEFINES ***********************/
#define MEMORY_CHUNK_SIZE 2
#define CMD_LINE_MAX_SIZE 300
#define MAX_ARG_SIZE 64
#define NUM_OF_ARRAYS 2
#define _VERTEX 1
#define _EDGE 0


#define ERROR_CODE int


#define CMD_NUM_OF_ARGS 2
#define CMD_NOT_RECOGNIZED 3
#define CMD_VRTX_NAME_NOT_VALID 4
#define VRTX_DUP_NAMES 5
#define VRTX_NOT_FOUND 6
#define CMD_FORMAT_INVALID 7
#define RMV_VRTX_EDGES 8
#define LOOP_NOT_ALLOWED 9
#define INVALID_WEIGHT 10
#define EDGE_DUP 11
#define EDGE_VRTX_NOT_FOUND 12
#define EDGE_MUST_BE_NUMBER 13
#define WEIGHT_NOT_NUMBER 14
#define EDGE_NOT_FOUND 15
#define INVALID_NUM_OF_CLUSTERS 16
#define VRTX_ID_MUST_BE_NUM 17
#define MEM_ALLOC_FAIL 18
#define VRTX_DUP_NAMES_ADD 19

#define AQUA "#00FFFF"
#define BLUE "#0000FF"
#define BLUEVIOLET "#8A2BE2"
#define BROWN "#A52A2A"
#define CHARTREUSE "#7FFF00"
#define DARKGREEN "#006400"
#define GOLD "#FFD700"
#define HOTPINK "#FF69B4"
#define ORANGERED "#FF4500"
#define SILVER "#C0C0C0"



/****************************************************/


/********************* FUNCTIONS ***********************/

bool handleCommand(char cmd_line[]);

ERROR_CODE addVertex(char name[]);

ERROR_CODE removeVertex(char name[]);

ERROR_CODE addEdge(char v1[], char v2[], char weight[]);

ERROR_CODE removeEdge(char idStr[]);

ERROR_CODE cluster(char clusters[]);

void print(bool isCluster);

void quitProperly();

bool handleError(bool condition, ERROR_CODE errorNumber);

bool checkForEdges(int id);

void freeArray(bool isVertices);

ERROR_CODE extendArray(bool isVertices);

void updateOpenSlot(int isVertices);

bool isName(char name[]);

bool isNumber(char name[]);

bool isDouble(char weight[]);

int getNumVertices();

int getNumEdges();

void printIntArray(int arr[], int arrLength);

void printCharArray(char arr[], int arrLength);

void printDoubleArray(double arr[], int arrLength);

int getVertexID(int e, int v);

double getEdgeWeight(int e);

int parseFile(char *filename, bool isVertices);

int handleInput(char *inputFolder);

int updateNetworkClusters(int kMax, double *x);

int printResults(char *resBuffer);

int createResultsFile(char *filename, double *objvals, int LB, int UB);

int buildXGMMLSolution(int nClusters, char *outputFolder, char bound);

int buildClustersColorsArray(int nClusters);
/****************************************************/


#endif	/* MISC_H */
